<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:winter="http://www.winter.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
	layout:decorator="/layouts/layout">
<head>
	<title>Controles</title>
</head>
<body>
	<section layout:fragment="content">
		<winter:output id="ControlesOutput">
			<form id="ControlesForm" th:object="${controles}" class="form">
				<h2 th:text="#{modulo.control.abm}" class="form-h1">Gestionar Control</h2>
				<div th:if="${controles.context.lista}">
					<winter:row>
			    	   <winter:column type="col-md-4">
			    	   		<winter:text
                                id="FiltroControlEscribano"
                                text="${beans.systemInfo.escribano.persona.nombreCompleto}"
                                class="winter-input-text capitalize"
								if="${beans.systemInfo.escribano}"
                                label="#{label.control.escribano}"
                                labeldisplay="col-xs-4"
								inputdisplay="col-xs-8"
								containerdisplay="row padded">
	                       </winter:text>
	                       <winter:select 
								id="NuevoselectEstado"
								field="*{filtros.estado}" 
								collection="est, rowEst : ${controles.estadosControl}"
								value="@{${est.id}+'|'+${est.descripcion}}"
								text="@{${est.descripcion}}"
								required="true"
								requiredmessage="Favor seleccione un Estado"
								modern="true"
								showglobalmessage="true"
								addemptyvalue="true"
								label="#{label.control.estado}"
								labeldisplay="col-xs-4"
								inputdisplay="col-xs-8"
								containerdisplay="row padded">
							</winter:select>
							<winter:inputtext
                                id="NuevoControlNroEscritura"
                                field="*{filtros.nroEscritura}"
                                class="winter-input-text capitalize"
								type="float"
								maxlength="20"
                                label="#{label.control.nroescritura}"
                                required="false"
                                labeldisplay="col-xs-4"
								inputdisplay="col-xs-8"
								containerdisplay="row padded">
	                       </winter:inputtext>
	                       <winter:inputtext
								id="NuevoControlNombreCompleto" 
								label="#{label.control.persona.nombre}"
								field="*{filtros.nombreCompleto}" 
								class="winter-input-text capitalize"
								type="char"
								chartypeerrormessage="Debe ser caracter"
								maxlength="200"
								labeldisplay="col-xs-4"
								inputdisplay="col-xs-8"
								containerdisplay="row padded">
							</winter:inputtext>
			    	   </winter:column>
			    	   <winter:column type="col-md-4">
			    	    	<winter:inputtext
								id="NuevaControlNro" 
								field="*{filtros.nroControl}"
								class="winter-input-text capitalize"
								label="#{label.control.nrocontrol}"
								labeldisplay="col-xs-4"
								inputdisplay="col-xs-8"
								containerdisplay="row padded">
							</winter:inputtext>
							<winter:datetimepicker
								id="FechaControlDesde"
								label="#{label.common.fechaDesde}"
								field="*{filtros.fechaDesde}"
								format="DD/MM/YYYY">
							</winter:datetimepicker>
							<winter:select 
								id="NuevoselectProtocolo"
								field="*{filtros.tipoProtocolo}" 
								collection="prot, rowprot : ${controles.tiposProtocolo}"
								value="@{${prot.id}+'|'+${prot.descripcion}}"
								text="@{${prot.descripcion}}"
								label="#{label.control.tipoprotocolo}"
								required="true"
								requiredmessage="Favor seleccione un Protocolo"
								modern="true"
								showglobalmessage="true"
								addemptyvalue="true"
								labeldisplay="col-xs-4"
								inputdisplay="col-xs-8"
								containerdisplay="row padded">
							</winter:select>
							<winter:inputtext
								id="NuevoControlOrdenEscritura"
								field="*{filtros.ordenEscritura}" 
								class="winter-input-text capitalize"
								label="#{label.control.nroorden}"
								labeldisplay="col-xs-4"
								inputdisplay="col-xs-8"
								containerdisplay="row padded"
								maxlength="200"
								type="char"
								chartypeerrormessage="Debe ser caracter">
							</winter:inputtext>
			    	   </winter:column>
			    	   <winter:column type="col-md-4">
			    	   		<winter:datetimepicker
								id="FechaControlHasta"
								label="#{label.common.fechaHasta}"
								field="*{filtros.fechaHasta}"
								format="DD/MM/YYYY">
							</winter:datetimepicker>
							<winter:textarea
								id="NuevoControlFolio"
								field="*{filtros.folio}" 
								class="winter-input-text capitalize"
								label="#{label.control.folio}"
								labeldisplay="col-xs-4"
								inputdisplay="col-xs-8"
								containerdisplay="row padded"
								maxlength="200"
								type="char"
								chartypeerrormessage="Debe ser caracter">
							</winter:textarea>
			    	   </winter:column>
			    	</winter:row>
				    <winter:row class="button-panel-right" padded="true">
				    	<winter:ajaxsubmit 
							id="@{'ConsultaControl'}" 
							form="ControlesForm"
							url="@{'/controles/buscarControles'}" 
							update="ControlesOutput"
							value="Consultar"
							object="controles"
							effect="fade"
							showstatus="true"
							class="btn btn-clear"
							immediate="true">
						</winter:ajaxsubmit>
						<winter:ajaxsubmit 
							id="@{'AgregarControl'}" 
							form="ControlesForm"
							url="@{'/controles/agregarControl'}" 
							update="ControlesOutput"
							value="Agregar Control"
							object="controles"
							effect="fade"
							showstatus="true"
							class="btn btn-clear"
							immediate="true">
						</winter:ajaxsubmit>
				    </winter:row>
				</div>			
				<div th:text="#{mensaje.controles.vacio}" class="info-message" th:if="${!controles.context.control and #lists.isEmpty(controles.controles)}">
				</div>
				<winter:output id="TablaControles">
					<winter:datatable 
						id="ListaControles"
						customLanguage="true"
						paginate="true"
						jQuery="true"
						retrieve="true"
						order="desc"
						ordencolumn="0"
						emptyTableText="No se encontraron Datos!"
						infoText="Mostrando _START_ al _END_ de _TOTAL_ registros"
						emptyTableInfoText="Mostrando 0 al 0 de 0 registros"
						searchText="Buscar"
						lengthMenu="Mostrar _MENU_ registros"
						if="${controles.context.lista and !#lists.isEmpty(controles.controles)}">
						<thead>
							<tr>
							    <th th:text="@{'Nro.Control'}"></th>
							    <th th:text="@{'Fecha'}"></th>
							    <th th:text="@{'Estado'}"></th>
								<th th:text="@{'Descripcion'}"></th>
								<th th:text="@{'Concepto'}"></th>
								<th th:text="@{'Referencia'}"></th>
								<th th:text="@{'Nro.Orden'}"></th>
								<th th:text="@{'Nro.Escritura'}"></th>
								<th th:text="@{'Protocolo'}"></th>
								<th th:text="@{'Folio'}"></th>
								<th th:text="@{'Operaciones'}"></th>
							</tr>
						</thead>
						<tbody>
							<tr th:each="controlItem, rowStat : ${controles.controles}" style="line-height: 2em;">
								<td th:text="${controlItem.nroControl}" class="align-center"></td>
								<td th:text="${controlItem.fecha}?${#dates.format(controlItem.fecha, 'dd/MM/yyyy')}:${controlItem.fecha}" class="align-center"></td>
								<td th:text="${controlItem.desEstado}"></td>
								<td th:text="${controlItem.descripcion}"></td>
								<td th:text="${controlItem.concepto}"></td>
								<td th:text="${controlItem.referencia}"></td>
								<td th:text="${controlItem.nroOrden}"></td>
								<td th:text="${controlItem.nroEscritura}"></td>
								<td th:text="${controlItem.desProtocolo}"></td>
								<td th:text="@{${#objects.nullSafe(controlItem.folioDesde,'')}+' - '+${#objects.nullSafe(controlItem.folioHasta,'')}}"></td>
								<td class="tabla-operaciones">
									<div class="button-toolbar">
										<winter:ajaxlink 
											id="@{${rowStat.index}+'EditarControl'}" 
											form="ControlesForm"
											url="@{'/controles/editarControl/'+${rowStat.index}}" 
											update="ControlesOutput"
											title="Editar"
											tip="true"
											object="controles"
											effect="fade"
											showstatus="true"
											immediate="true"
											class="ajax-submit icon-edit-sign icon-2x">
										</winter:ajaxlink>
										<winter:ajaxlink 
											id="@{${rowStat.index}+'EliminarControl'}" 
											form="ControlesForm"
											url="@{'/controles/eliminarControl/'+${rowStat.index}}" 
											update="ControlesOutput"
											title="Eliminar"
											tip="true"
											object="controles"
											effect="fade"
											showstatus="true"
											immediate="true"
											class="ajax-submit icon-remove-sign icon-2x"
											confirmationrequired="true"
							                confirmationtext="Está seguro que desea realizar la operación?">
										</winter:ajaxlink>
										<winter:ajaxlink 
											id="@{${rowStat.index}+'Seguimiento'}" 
											form="ControlesForm"
											url="@{'/controles/seguimiento/'+${rowStat.index}}" 
											update="ControlesOutput"
											title="Notas"
											tip="true"
											class="ajax-submit fa-book icon-2x"
											object="controles"
											effect="fade"
											showstatus="true"
											immediate="true">
										</winter:ajaxlink>
										<winter:ajaxlink 
											id="@{${rowStat.index}+'DetalleControl'}" 
											form="ControlesForm"
											url="@{'/controles/controlFormulario/'+${rowStat.index}}"
											update="ControlesOutput"
											title="Formularios"
											tip="true"
											class="ajax-submit fa-list-ul icon-2x"
											object="controles"
											effect="fade"
											showstatus="true"
											immediate="true">
										</winter:ajaxlink>
										<winter:ajaxlink 
											id="@{${rowStat.index}+'Escrituras'}" 
											form="ControlesForm"
											url="@{'/controles/controlEscritura/'+${rowStat.index}}" 
											update="ControlesOutput"
											title="Escrituras"
											tip="true"
											class="ajax-submit fa-pencil-square-o icon-2x"
											object="controles"
											effect="fade"
											showstatus="true"
											immediate="true">
										</winter:ajaxlink>
										<winter:ajaxlink 
											id="@{${rowStat.index}+'Textos'}" 
											form="ControlesForm"
											url="@{'/controles/texto/'+${rowStat.index}}"
											update="ControlesOutput"
											title="Textos"
											tip="true"
											class="ajax-submit fa-file-text-o icon-2x"
											object="controles"
											effect="fade"
											showstatus="true"
											immediate="true">
										</winter:ajaxlink>
									</div>
								</td>
							</tr>
						</tbody>
					</winter:datatable>
				</winter:output>
				<div th:if="${controles.context.control}" class="regla">
					<div id="CrearEditarControl" th:include="/admin/control :: control">
	  				</div>
				</div>
				<div th:if="${controles.context.formulario}" class="regla">
					<div id="CrearEditarFormulario" th:include="/admin/controlFormulario :: formulario">
	  				</div>
				</div>	
				<div th:if="${controles.context.nota}" class="regla">
					<div id="SeguimientoControl" th:include="/admin/controlNota :: NotaFragment">
	  				</div>
				</div>
				<div th:if="${controles.context.escritura}" class="regla">
					<div id="CrearEditarEscritura" th:include="/admin/controlEscritura :: escritura">
	  				</div>
				</div>
				<div th:if="${controles.context.texto}" class="regla">
					<div id="CrearEditarTexto" th:include="/admin/controlTexto :: texto">
	  				</div>
				</div>					
			</form>
		</winter:output>
	</section>
</body>
</html>